# coding = utf-8

import tkinter as tk
from tkinter import filedialog
import vlc

class VideoPlayer:
    def __init__(self):
        self.instance = vlc.Instance()
        self.player = self.instance.media_player_new()

        # Create window and canvas
        self.window = tk.Tk()
        self.window.title("Video Player")

        self.canvas = tk.Canvas(self.window, width=640, height=480)
        self.canvas.pack()

        # Create buttons
        btn_open = tk.Button(self.window, text="Open", command=self.open_file)
        btn_open.pack()

        btn_play = tk.Button(self.window, text="Play", command=self.play)
        btn_play.pack()

        btn_pause = tk.Button(self.window, text="Pause", command=self.pause)
        btn_pause.pack()

        btn_stop = tk.Button(self.window, text="Stop", command=self.stop)
        btn_stop.pack()

        # Initialize video parameters
        self.video_path = ""
        self.media = None

        self.window.mainloop()

    def open_file(self):
        # Select video file
        self.video_path = filedialog.askopenfilename(title="Select video file", filetypes=(("MP4", "*.mp4"), ("All files", "*.*")))

        # Load media
        if self.video_path != "":
            self.media = self.instance.media_new(self.video_path)
            self.player.set_media(self.media)

    def play(self):
        if self.media is not None:
            self.player.play()

    def pause(self):
        if self.media is not None:
            self.player.pause()

    def stop(self):
        if self.media is not None:
            self.player.stop()

# Create VideoPlayer object
player = VideoPlayer()



